package com.qiaolang.db;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * Created by lenovo on 2017/11/12.
 */
public class DB {
    private static Connection conn=null;
    public static Connection getConnection(){//得到连接对象
        try {
            // 1. 注册驱动
            Class.forName("com.mysql.jdbc.Driver");
            // 2. 获取数据库的连接
            conn= DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8","root","root");

        } catch (Exception e) {
            e.printStackTrace();
        }
        return conn;
    }
}
